package com.everflourish.yeah100.act.base;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.KeyEvent;

import com.android.volley.RequestQueue;
import com.everflourish.yeah100.utils.IntentUtil;
import com.everflourish.yeah100.utils.SystemApp;
import com.everflourish.yeah100.utils.constant.AnimEnum;

/**
 * 基础的fragmentActivity
 *
 * @author pf
 * @date 2015-1-8
 */
public class BaseFragmentActivity extends FragmentActivity {

    public Context mContext;
    public SystemApp mSystemApp;
    public RequestQueue mQueue;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mSystemApp = SystemApp.getInstance();
        mSystemApp.addStack(this);
        mContext = this;
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mQueue != null) {
            mQueue.stop();
        }
        mSystemApp.delActivity(this);
    }

    public boolean onKeyUp(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            IntentUtil.finishActivity(this, AnimEnum.TRANSLATE_HORIZONTAL);
            return true;
        } else {
            return super.onKeyUp(keyCode, event);
        }
    }
}
